home *** CD-ROM | disk | FTP | other *** search
- *******************************************************************************
- * STatus Disk Magazine *
- * Issue 1, Volume 1 *
- * *
- * NOTE: This issue is to be copied freely by Atari ST users. We at STatus *
- * strictly prohibit anyone selling this issue as part of a Shareware or PD *
- * collection. *
- * *
- * STatus Disk Magazine *
- * Suite 299 *
- * 4431 Lehigh Road *
- * College Park, MD 20740 *
- * *
- * STatus Disk Magazine (c) 1989, is a COMMERCIAL effort. *
- *******************************************************************************
-
- How to Display a Spectrum Picture in GFA Basic
-
-
- Thanks to Trio Engineering's Spectrum 512, we all can enjoy
- seeing 320x200 pictures with 512 colors at once. However, even
- now, not much else in the realm of the Atari ST graphics has
- broken the 16 color barrier, and no other program has done it in
- such a clean method. After using Quantum Paint 4096, and it's
- promised 4096 color at once display, I was somewhat disappointed,
- since it was to use only 5% of the ST's CPU time, unlike
- Spectrum's 80%, but this is not a review of Spectrum, but a
- tutorial on how to work with Spectrum pictures in GFA Basic.
-
- For this example, I used GFA Basic v2.02 (now that the GFA
- Compiler for Basic v3.0 is out, I'll upgrade!). There are two
- files required to make this work, that were released into the PD
- by Trio Engineering a while back. These are:
-
- SHOW512.O - this actually pre-empts the normal ST video
- display and implements what I term the
- "Spectrum technique".
- DECOMP.O - this is a module that will decompress an .SPC
- pic into a SPU format pic, which is the actual
- display format Spectrum 512 pictures use.
-
- The Spectrum picture, decompressed, is always 51104 bytes.
- Here is the format of the picture:
-
- 32000 bytes - raw screen data
- 19104 bytes - palette data
-
- The 19104 bytes stems from the fact that it is using 3
- palettes per scanline for 199 (not 200) scanlines, and each
- palette is 16 words (32 bytes). So, for each scanline, 1 - 199
- inclusive (scanline 0 is always blank), we have 96 bytes of
- palette data, so the total is 199 * 96 bytes = 19104 bytes.
-
- Now there are two main criteria to remember. The first is
- that the ST requires any displayable screen to have it's starting
- address be evenly divisible by 256. This is because the video
- chip cannot truly access all 4 megabytes available from the ST
- MMU, so, in order to allow for relocatable screens throughout a 4
- meg system, Atari made the video Shifter ignore the lowest byte of
- address data. This means that when you reserve space for Spectrum
- picture, you must give yourself about 255 bytes leeway, in case
- the location is not evenly divisible by 256. My routine, for
- a GEM M_alloc (reserve memory) call will do this automatically,
- and return in the variable "Adr" the address that is acceptable.
- If you note, I reserve 104000 bytes, which is enough for two full
- size uncompressed pictures. That is because I need 51104 for the
- decompressed displayable picture, and space for the picture before
- decompression. The second criteria is to boot in the routines
- made by Trio, into "blanked" out areas of memory. I do this by
- zeroing out a string of the same length as the module I boot in
- with the SPACE$ command, and then booting the module in via my
- loader routine.
-
- Now the next step is the get the filename to view. The
- viewer uses the file selector, which is easily enough done in GFA
- Basic. If the user doesn't pick a file, it will terminate.
-
- The final two steps are to call in the routines that actually
- decompress the .SPC file and display the uncompressed picture.
- Trio states that mouse routines will not work reliably, and also,
- GEM file operations will wreck the display, sending it back to 16
- color mode. So, when displaying a picture, your best bet is to
- plan for keyboard input only. I do this via the INKEY$ so the
- system waits for a keypress before showing the file selector
- again.
-
- The variables used in this are Spc% (address of the
- uncompressed picture data),Bitm% (address of the bit map
- data/screen data..the 32000 byte portion of the uncompressed
- picture), and Colm% (address of the palette/color information).
- The two are made contiguous for my purposes, but could reside in
- totally different areas of memory. When de-arc'ing the picture, I
- simply use:
-
- Dummy = C:Decom%(L:Spc%,Bitm%,L:Colm%)
-
- what this really does is says to GFA Basic is to run
- DECOMP.O, (which we booted in, and remembered the starting
- address of it as Decom%!), and to pass three longwords to it,
- which are the previously described variables Spc%, Bitm% and
-
- Colm%. We also check the value for Dummy to make sure that it
- is a 0 which is DECOMP.O's way of telling you all
- went well with the decompression.
-
- The display routine, SHOW512.O is called similarly. We don't
- need to worry about an error code or any return value, so we use:
-
- Void C: Show%(1,L:Bitm%,L:Colm%)
-
- this calls the SHOW512.O routine, located at Show%, and tells
- it to display, using the "Spectrum Technique" the picture whose
- address (uncompressed) is at Bitm% and whose palette is at the
- address Colm%. The number "1" you in the parentheses tells the
- routine how often to keep this screen up on display. I send it
- the value "1" to keep it up 1/60th of a second at a time.
-
- Now that I have shown how to display a Spectrum compressed
- picture the next logical step would be animating them. That can
- be accomplished by booting in a series of pictures, decompressing
- and using the display code with variable frame speeds.
-
- Another, more difficult thing to try would be to create
- vertical scrolling through several Spectrum 512 pictures. This
- would require setting up the palette data for all the pictures in
- one area, and put the pictures all together in another area, and
- as you move through the pictures, you increment a pointer to the
- proper address for the colors. Perhaps this is material for a
- later GFA tutorial.
-
- Also, in passing, I'd like to thank a BBSer who used to call
- LD to Washington, D.C. named Pat Steele who helped me figure this
- out when the Trio code first became available.
-
- Finally, I'd like to encourage others to experiment with
- this, and perhaps bring us a few 512 color programs!
-
-
-
-